﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;

namespace Dune2013
{
    public class NodeManager
    {
        static NodeManager instance;
        private NodeManager() { }
        public static NodeManager getInstance()
        {
            if (instance == null)
                instance = new NodeManager();
            return instance;
        }
        public Node makeMainBase(Node mainBase)
        { 
            mainBase.type = Node.NODE_TYPE.BASE;
            mainBase.obstacle = false;
            mainBase.emptyTexture(); //para que la actualice
            //mainBase.tex = StaticStuff.getTextureById(StaticStuff.tiposTexturas.BASE);
            return mainBase;
        }
        public Node makeStation(Node station)
        {
            station.type = Node.NODE_TYPE.STATION;
            station.obstacle = false;
            station.emptyTexture(); //para que la actualice
            //station.tex = StaticStuff.getTextureById(StaticStuff.tiposTexturas.ESTACION);
            return station;
        }
        public Node makePOI(Node poi, int oil)
        {
            poi.type = Node.NODE_TYPE.POI;
            poi.oil = oil;
            poi.obstacle = false;
            poi.emptyTexture(); //para que la actualice
            //poi.tex = StaticStuff.getTextureById(StaticStuff.tiposTexturas.POZO_SIMPLE);
            return poi;
        }
        public Node makeEmpty(Node empty)
        {
            empty.type = Node.NODE_TYPE.EMPTY;
            empty.oil = 0;
            empty.obstacle = false;
            empty.emptyTexture(); //para que la actualice
            //empty.tex = StaticStuff.getTextureById(StaticStuff.tiposTexturas.EMPTY);
            return empty;
        }
        public Node makeBuildingWell(Node buildWell) {
            buildWell.type = Node.NODE_TYPE.BUILDING_WELL;
            buildWell.obstacle = false;
            buildWell.emptyTexture(); //para que la actualice
            //buildWell.tex = StaticStuff.getTextureById(StaticStuff.tiposTexturas.BUILDING_WELL);
            return buildWell;
        }
        public Node makeWell(Node well)
        {
            well.type = Node.NODE_TYPE.WELL;
            well.obstacle = false;
            well.emptyTexture(); //para que la actualice
            //well.tex = StaticStuff.getTextureById(StaticStuff.tiposTexturas.WELL);
            return well;
        }
        public Node makeObs(Node obs)
        {
            obs.type = Node.NODE_TYPE.OBSTACULE;
            obs.obstacle = true;
            obs.emptyTexture(); //para que la actualice
            //obs.tex = StaticStuff.getTextureById(StaticStuff.tiposTexturas.OBSTACULO); ;
            return obs;
        }
        public Texture2D getAppropiateTexture(Node node) {
            switch (node.type) { 
                case Node.NODE_TYPE.NOTHING:
                    return StaticStuff.getTextureById(StaticStuff.tiposTexturas.NADA);
                case Node.NODE_TYPE.BASE:
                    return StaticStuff.getTextureById(StaticStuff.tiposTexturas.BASE);
                case Node.NODE_TYPE.STATION:
                    return StaticStuff.getTextureById(StaticStuff.tiposTexturas.ESTACION);
                case Node.NODE_TYPE.WELL:
                case Node.NODE_TYPE.BUILDING_WELL:
                    return StaticStuff.getTextureById(StaticStuff.tiposTexturas.POZO_CONSTRUIDO);
                case Node.NODE_TYPE.POI:
                    return StaticStuff.getTextureById(StaticStuff.tiposTexturas.POZO_SIMPLE);
                case Node.NODE_TYPE.EMPTY:
                    return StaticStuff.getTextureById(StaticStuff.tiposTexturas.POZO_VACIO);
                case Node.NODE_TYPE.OBSTACULE:
                    return StaticStuff.getTextureById(StaticStuff.tiposTexturas.OBSTACULO);
            }
            return null;
        }
    }
}
